from DbProvider import DbProvider
import os
import json
import requests
from email.mime.text import MIMEText
import smtplib

def Main():
    server = r'LOCALHOST\SQLEXPRESS'
    database = 'dev'
    username = 'dev'
    password = 'a.o7a@bj'
    
    sqlStr = 'SELECT Id, Name, Email FROM UserObject'

    provider = DbProvider(server = server, username = username, passwd = password, database = database)
    curcor = provider.ExecuteQuerySql(insertStr, parameters)
    row = curcor.fetchone()
    while row:
        print(row[0] + "  " + row[1])
        row = curcor.fetchone()


def Test():
    server = r'LOCALHOST\SQLEXPRESS'
    database = 'dev'
    username = 'dev'
    password = 'a.o7a@bj'
    
    insertStr = "insert into TeamSite (id,name,description) values(?,?,?)"

    provider = DbProvider(server = server, username = username, passwd = password, database = database)
    parameters = ('2','peyton','des')
    curcor = provider.ExecuteNullQuery(insertStr, parameters)
    provider.cnxn.close()

from_addr = 'peytonzhang@seismic.com'
to_addr = 'peytonzhang@objectivasoftware.com'
msg = MIMEText('测试', 'plain', 'utf-8')
msg['Subject'] = '这是一个python测试'
msg['From'] = 'peytonzhang@seismic.com'
msg['To'] = 'peytonzhang@objectivasoftware.com'
server = smtplib.SMTP_SSL('cex.seismic.com', 2525) # SMTP协议默认端口是25
server.set_debuglevel(1)
server.login(from_addr)
server.sendmail(from_addr, [to_addr], msg.as_string())
server.quit()